package http.secure.common.config;

import http.secure.common.filter.SecureRequestFilter;
import jakarta.servlet.Filter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.Collections;

/**
 * Security request filter configuration
 */
@Configuration
public class SourceFilterRegistration {

    @Bean
    public FilterRegistrationBean<Filter> MyRegistrationBean(SecureRequestFilter filter) {
        FilterRegistrationBean<Filter> registrationBean = new FilterRegistrationBean<>();
        registrationBean.setFilter(filter::filter);
        registrationBean.setUrlPatterns(Collections.singleton("/*"));
        registrationBean.setOrder(-1);
        return registrationBean;
    }
}